package com.sitanyun.merchant.guide.model.impl;

import com.google.gson.Gson;
import com.sitanyun.merchant.guide.bean.SmsPhoneBean;
import com.sitanyun.merchant.guide.callback.StringCallbacks;
import com.sitanyun.merchant.guide.frament.presenter.callback.CallBack;
import com.sitanyun.merchant.guide.model.inter.ISetingPaswdAModel;
import com.sitanyun.merchant.guide.url.Urls;
import com.sitanyun.merchant.guide.weiht.SharedPreferenceUtil;
import com.zhy.http.okhttp.OkHttpUtils;

import java.util.HashMap;

import okhttp3.Call;
import okhttp3.MediaType;

public class SetingPaswdAModelImpl implements ISetingPaswdAModel {
    @Override
    public <T> void setingpswd(String name, String password, String id, String phone, CallBack callBack) {

        HashMap<String,String> hashMap= new HashMap<String,String>();
        hashMap.put("userId",name);
        hashMap.put("newPassword",password);
            OkHttpUtils.postString()
                    .addHeader("Content-Type","application/json")
                    .addHeader("Authorization","Bearer "+ SharedPreferenceUtil.getStringData("token"))
                    .mediaType(MediaType.parse("application/json; charset=utf-8"))
                    .url(Urls.edit)
                    .content(new Gson().toJson(hashMap))
                    .build().execute(new StringCallbacks() {
                @Override
                public void onError(Call call, Exception e, int id) {
                }
                @Override
                public void onResponse(String response, int id) {
                    SmsPhoneBean baseEntity=  new Gson().fromJson(response, SmsPhoneBean.class);
                callBack.onSuccess(baseEntity);
                }
            });


    }
}
